package com.sina.weibo;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.sina.weibo.models.Message;
import com.sina.weibo.models.User;
import com.sina.weibo.view.MessageListItemView;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MessageList extends ListBaseActivity
  implements View.OnClickListener
{
  public static final int maxMsgLength = 300;
  String cache;
  int expanded = -1;
  MessageListAdapter mAdapter;
  ListView mMessageListView;
  String mNick;
  Dialog mPgDialog;
  boolean mPostTaskFree = 1;
  boolean mPrefShowPicture = 0;
  String mPrvtMsg;
  private int mReadMode;
  ListBaseActivity.FetchDataTask mTask;
  boolean mTaskFree = 1;
  String mUid;
  User mUser;
  Dialog pgrdlg;

  protected void doItemMenu(String paramString)
  {
    if ((!TextUtils.isEmpty(paramString)) && (Utils.getWebPattern().matcher(paramString).matches()))
    {
      Intent localIntent1 = new Intent("android.intent.action.VIEW");
      Uri localUri = Uri.parse(paramString);
      Intent localIntent2 = localIntent1.setData(localUri);
      startActivity(localIntent1);
    }
  }

  protected BaseAdapter getAdapter()
  {
    if (this.mAdapter == null);
    for (MessageListAdapter localMessageListAdapter = new MessageListAdapter(); ; localMessageListAdapter = null)
      return localMessageListAdapter;
  }

  protected List<CharSequence> getMenuContent()
  {
    return null;
  }

  protected Object[] getMessages(int paramInt1, int paramInt2)
  {
    Object localObject1 = null;
    Object[] arrayOfObject1 = (Object[])localObject1;
    try
    {
      RPCHelper localRPCHelper = RPCHelper.getInstance(getApplication());
      User localUser = this.mUser;
      String str = this.mUid;
      Object[] arrayOfObject2 = localRPCHelper.getMessageList(localUser, str, paramInt1, 25);
      Object[] arrayOfObject3 = arrayOfObject2;
      if (arrayOfObject3[0] != 0)
      {
        int i = ((Integer)arrayOfObject3[0]).intValue();
        this.mTotals = i;
        Object localObject2 = arrayOfObject3;
        return localObject2;
      }
    }
    catch (RPCHelper.HttpException localHttpException)
    {
      while (true)
      {
        continue;
        int j = 0;
      }
    }
  }

  protected void handleListItemClickEvent(int paramInt)
  {
    int i = this.mExpectItem - 1;
    switch (paramInt)
    {
    default:
      return;
    case 1:
    }
    Resources localResources = getResources();
    ArrayList localArrayList1 = new ArrayList();
    String str1 = localResources.getString(2131427513);
    boolean bool1 = localArrayList1.add(str1);
    Object localObject = this.mList.get(i);
    Matcher localMatcher;
    if ((localObject instanceof Message))
    {
      Message localMessage = (Message)localObject;
      Pattern localPattern = Utils.getWebPattern();
      String str2 = localMessage.content;
      localMatcher = localPattern.matcher(str2);
    }
    while (true)
    {
      if (!localMatcher.find())
      {
        AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(this);
        ArrayList localArrayList2 = localArrayList1;
        AlertDialog.Builder localBuilder2 = localBuilder1.setTitle(2131427362);
        CharSequence[] arrayOfCharSequence1 = new CharSequence[0];
        CharSequence[] arrayOfCharSequence2 = (CharSequence[])localArrayList2.toArray(arrayOfCharSequence1);
        MessageList.1 local1 = new MessageList.1(this, localArrayList2);
        AlertDialog.Builder localBuilder3 = localBuilder1.setItems(arrayOfCharSequence2, local1);
        localBuilder1.create().show();
        break;
      }
      String str3 = localMatcher.group();
      boolean bool2 = localArrayList1.add(str3);
    }
  }

  protected void handleTaskResult(List<?> paramList, String paramString)
  {
    if (paramList != null)
      if (this.mList == null)
      {
        this.mList = paramList;
        List localList1 = this.mList;
        int i = this.mTotals;
        String str1 = this.mUid;
        String str2 = this.cache;
        User localUser1 = this.mUser;
        Utils.saveSubMessageListFile(localList1, i, str1, str2, localUser1);
      }
    label206: 
    while (true)
    {
      return;
      if (paramList.size() > 0)
      {
        boolean bool = this.mList.addAll(paramList);
        List localList2 = this.mList;
        int j = this.mTotals;
        String str3 = this.mUid;
        String str4 = this.cache;
        User localUser2 = this.mUser;
        Utils.saveSubMessageListFile(localList2, j, str3, str4, localUser2);
        continue;
      }
      int k = this.mPage - 1;
      this.mPage = k;
      continue;
      if (StaticInfo.mUser == null)
        continue;
      if (paramString != null)
        Toast.makeText(this, paramString, 0).show();
      while (true)
      {
        if ((this.mList != null) && (this.mList.size() != 0))
          break label206;
        loadCache();
        break;
        String str5 = getString(2131427410);
        Toast.makeText(this, str5, 0).show();
      }
    }
  }

  protected void handleTitleBarEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 0:
    case 1:
    }
    while (true)
    {
      return;
      String str = this.mNick;
      Intent localIntent = Utils.editPrivateMessage(this, str);
      startActivity(localIntent);
      continue;
      finish();
    }
  }

  protected void loadCache()
  {
    if (this.mUser == null);
    String str1;
    String str2;
    User localUser;
    for (Object[] arrayOfObject = null; ; arrayOfObject = Utils.loadSubMessageListFile(str1, str2, localUser))
    {
      if (arrayOfObject != null)
      {
        int i = ((Integer)arrayOfObject[0]).intValue();
        this.mTotals = i;
        List localList = (List)arrayOfObject[1];
        this.mList = localList;
      }
      return;
      str1 = this.mUid;
      str2 = this.cache;
      localUser = this.mUser;
    }
  }

  protected void loadMore(int paramInt)
  {
    reloadBegine(0);
    this.mExpectItem = paramInt;
    if (this.mTaskFree)
    {
      ListBaseActivity.FetchDataTask localFetchDataTask1 = new ListBaseActivity.FetchDataTask(this);
      this.mTask = localFetchDataTask1;
      int i = this.mPage + 1;
      this.mPage = i;
      String str = String.valueOf(i);
      ListBaseActivity.FetchDataTask localFetchDataTask2 = this.mTask;
      String[] arrayOfString = new String[1];
      arrayOfString[0] = str;
      AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
    }
  }

  public void onClick(View paramView)
  {
    super.onClick(paramView);
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    String str1 = getString(2131427528);
    String str2 = getString(2131427372);
    String str3 = getString(2131427435);
    setTitleBar(1, str1, str2, str3);
    ListView localListView = this.mlvBase;
    this.mMessageListView = localListView;
    boolean bool = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("show_picture", 1);
    this.mPrefShowPicture = bool;
    String str4 = getCacheDir().getPath();
    this.cache = str4;
    User localUser = Utils.loadUserFile(this.cache);
    this.mUser = localUser;
    Bundle localBundle = getIntent().getExtras();
    String str5 = localBundle.getString("nick");
    this.mNick = str5;
    String str6 = localBundle.getString("uid");
    this.mUid = str6;
    MessageListAdapter localMessageListAdapter = new MessageListAdapter();
    this.mAdapter = localMessageListAdapter;
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    return false;
  }

  protected void onPause()
  {
    super.onPause();
    if ((!this.mTaskFree) && (this.mTask != null) && (!this.mTask.isCancelled()))
    {
      this.mTaskFree = 1;
      boolean bool = this.mTask.cancel(1);
    }
  }

  protected void onResume()
  {
    super.onResume();
    int i = getSharedPreferences("readmode", 0).getInt("readmode", 0);
    if (this.mReadMode != i)
    {
      this.mReadMode = i;
      this.mAdapter.notifyDataSetChanged();
    }
    if ((this.mList == null) && (this.mTaskFree))
      reloadList();
    while (true)
    {
      return;
      this.mMessageListView.setVisibility(0);
      ((MessageListAdapter)this.mMessageListView.getAdapter()).refresh();
    }
  }

  protected void reloadList()
  {
    reloadBegine(1);
    this.mBeReload = 1;
    this.mPage = 1;
    this.mNewCount = 0;
    if (this.mTaskFree)
    {
      String str = String.valueOf(this.mPage);
      if ((this.mTask != null) && (!this.mTask.isCancelled()))
        boolean bool = this.mTask.cancel(1);
      ListBaseActivity.FetchDataTask localFetchDataTask1 = new ListBaseActivity.FetchDataTask(this);
      this.mTask = localFetchDataTask1;
      ListBaseActivity.FetchDataTask localFetchDataTask2 = this.mTask;
      String[] arrayOfString = new String[1];
      arrayOfString[0] = str;
      AsyncTask localAsyncTask = localFetchDataTask2.execute(arrayOfString);
    }
    this.mExpectItem = 1;
  }

  protected void saveListCache(int paramInt, List<?> paramList)
  {
    if ((this.mUser != null) && (paramList != null))
    {
      int i = this.mTotals;
      String str1 = this.mUid;
      String str2 = this.mCacheDir;
      User localUser = this.mUser;
      Utils.saveSubMessageListFile(paramList, i, str1, str2, localUser);
    }
  }

  protected void setContentView()
  {
    setView(2130903060);
  }

  class MessageListAdapter extends BaseAdapter
  {
    public MessageListAdapter()
    {
    }

    public int getCount()
    {
      int i;
      if (MessageList.this.mList == null)
        i = 0;
      while (true)
      {
        return i;
        int j = MessageList.this.mList.size();
        int k = MessageList.this.mTotals;
        if (j < k)
        {
          i = MessageList.this.mList.size() + 2;
          continue;
        }
        i = MessageList.this.mList.size() + 1;
      }
    }

    public Object getItem(int paramInt)
    {
      return Integer.valueOf(paramInt);
    }

    public long getItemId(int paramInt)
    {
      return paramInt;
    }

    public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
    {
      paramInt += -1;
      int i = paramInt;
      int j = -1;
      if (i == j);
      for (Object localObject1 = MessageList.this.getReloadView(); ; localObject1 = MessageList.this.getLoadMoreView())
      {
        return localObject1;
        int k = MessageList.this.mList.size();
        int m = paramInt;
        int n = k;
        if (m != n)
          break;
      }
      int i1 = MessageList.this.expanded;
      int i2 = paramInt;
      int i3;
      label94: Object localObject2;
      if (i1 == i2)
      {
        i3 = 1;
        if (paramView != null)
          break label194;
        MessageList localMessageList1 = MessageList.this;
        ListView localListView1 = MessageList.this.mMessageListView;
        List localList1 = MessageList.this.mList;
        int i4 = paramInt;
        Message localMessage1 = (Message)localList1.get(i4);
        boolean bool1 = MessageList.this.mPrefShowPicture;
        int i5 = MessageList.this.mReadMode;
        localObject2 = new MessageListItemView(localMessageList1, localListView1, localMessage1, 0, bool1, 0, i5);
      }
      while (true)
      {
        localObject1 = localObject2;
        break;
        i3 = 0;
        break label94;
        label194: localObject2 = paramView;
        try
        {
          MessageListItemView localMessageListItemView = (MessageListItemView)localObject2;
          List localList2 = MessageList.this.mList;
          int i6 = paramInt;
          Object localObject3 = localList2.get(i6);
          boolean bool2 = MessageList.this.mPrefShowPicture;
          int i7 = MessageList.this.mReadMode;
          localMessageListItemView.update(localObject3, i3, bool2, 0, i7);
        }
        catch (Exception localException)
        {
          localObject2 = new com/sina/weibo/view/MessageListItemView;
          MessageList localMessageList2 = MessageList.this;
          ListView localListView2 = MessageList.this.mMessageListView;
          List localList3 = MessageList.this.mList;
          int i8 = paramInt;
          Message localMessage2 = (Message)localList3.get(i8);
          boolean bool3 = MessageList.this.mPrefShowPicture;
          int i9 = MessageList.this.mReadMode;
          Object localObject4 = localObject2;
          int i10 = i3;
          localObject4.<init>(localMessageList2, localListView2, localMessage2, i10, bool3, 0, i9);
        }
      }
    }

    public int getViewTypeCount()
    {
      return 2;
    }

    public void refresh()
    {
      notifyDataSetChanged();
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.MessageList
 * JD-Core Version:    0.6.0
 */